//
//  NewPasswordViewController.swift
//  ShiZhe
//
//  Created by 陈卿伟 on 16/8/31.
//  Copyright © 2016年 陈卿伟. All rights reserved.
//

import UIKit



class NewPasswordViewController: MainViewController {
    var newPasswordView:NewPasswordView!
    override func viewDidLoad() {
        super.viewDidLoad()
        self.title = "新密码"
        self.addSMSView()
        self.addTargetToView()
    }
}

//MARK:--UI
extension NewPasswordViewController{
    //将view添加进来
    func addSMSView(){
        newPasswordView = NewPasswordView(frame: MainBounds)
        self.view.addSubview(newPasswordView)
    }
    
    //给控件添加点击事件
    func addTargetToView(){
        //登录按钮点击事件
        newPasswordView.logButton.addTarget(self, action: #selector(self.logButtonClick(_:)), forControlEvents: .TouchUpInside)
    }
}

//MARK:--点击事件
extension NewPasswordViewController{
    //登录按钮点击事件
    func logButtonClick(sender:UIButton){
        let password = newPasswordView.password
        let passwordAgain = newPasswordView.passwordAgain
        if password?.text?.characters.count<6 || password?.text?.characters.count>20 || passwordAgain?.text?.characters.count<6 || passwordAgain?.text?.characters.count>20 {
            showHUD.showTopHud(self.view, text: "请输入大于6位 小于20位的密码")
        }else if password?.text != passwordAgain?.text{
            showHUD.showTopHud(self.view, text: "两次输入的密码不一致")
        }else{
            password?.resignFirstResponder()
            passwordAgain?.resignFirstResponder()
            //接下来有数据再说
        }
        
    }
}












